<!DOCTYPE html>
<html class="loginHtml">
<head>
	<meta charset="utf-8">
	<title>登录</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" />
</head>
<body class="loginBody">
	<form class="layui-form">
		<div style="height: 50px;"></div>
		<div class="layui-form-item input-item layui-input-active">
			<label for="loginName">账号</label>
			<input type="text" id="loginName" value="${sysUserVo.loginName}"  class="layui-input" lay-verify="required">
		</div>
		<div class="layui-form-item input-item layui-input-active">
			<label for="password">密码</label>
			<input type="password" id="password" value="${sysUserVo.password}"  class="layui-input" lay-verify="required">
		</div>
		<div class="layui-form-item input-item layui-input-active" id="imgCode">
			<label for="code">验证码</label>
			<input type="text" id="inputYZM" placeholder="请输入验证码" id="code" class="layui-input">
			<div id="yzmContent"> </div>
		</div>
		<div class="layui-form-item input-item">
			<input type="checkbox" lay-skin="primary" title="自动登录" id="loginCheck" <#if sysUserVo.autoLogin = 2>checked</#if>>
		</div>
		<div class="layui-form-item">
			<button class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
		</div>
	</form>
	<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
	<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
	<script  type="application/javascript" src="${s.base}/lib/gVerify.js"></script>
	<script  type="application/javascript">
        layui.use(['form','layer','jquery','checkUtil','dialogUtil','baseUtil'],function(){
            var form = layui.form,
                checkUtil = layui.checkUtil,
                baseUtil = layui.baseUtil,
                dialogUtil = layui.dialogUtil,
                layer = parent.layer === undefined ? layui.layer : top.layer
            $ = layui.jquery;
            var verifyCode = new GVerify("yzmContent");//初始化验证码
            //登录按钮
            form.on("submit(login)",function(data){
                var autoLogin=2;//是否自动登录，2.否，1.是
                var loginName=$("#loginName").val();
                var password=$("#password").val();
                var inputYZM=$("#inputYZM").val();
                if(checkUtil.isEmpty(loginName)){
                    dialogUtil.alert("请输入登录名！");
                    return false;
                }
                if(checkUtil.isEmpty(password)){
                    dialogUtil.alert("请输入密码！");
                    return false;
                }
                if(checkUtil.isEmpty(inputYZM)){
                    dialogUtil.alert("请输入验证码！");
                    return false;
                }
                var res = verifyCode.validate(inputYZM);
                if(!res){
                    dialogUtil("验证码输入错误！");
                    return false;
                }
                if($("#loginCheck").is(":checked")){
                    autoLogin=1;
                }
                var url="webLogin";
                var params = {
                    loginName: loginName,
                    autoLogin: autoLogin,
                    password:password
                };
                $(this).text("登录中...").attr("disabled","disabled").addClass("layui-disabled");
                var obj=$(this);
                baseUtil.postMethod(url,params,function (result) {
                    obj.text("登录").removeAttr("disabled").removeClass("layui-disabled");
                    if (result.code === 0) {
                        //操作成功
                        location.href="index";
                    } else {
                        //操作失败
                        dialogUtil.alert(result.msg);
                    }
                })
                return false;
            })

            //表单输入效果
            $(".loginBody .input-item").click(function(e){
                e.stopPropagation();
                $(this).addClass("layui-input-focus").find(".layui-input").focus();
            })
            $(".loginBody .layui-form-item .layui-input").focus(function(){
                $(this).parent().addClass("layui-input-focus");
            })
            $(".loginBody .layui-form-item .layui-input").blur(function(){
                $(this).parent().removeClass("layui-input-focus");
                if($(this).val() != ''){
                    $(this).parent().addClass("layui-input-active");
                }else{
                    $(this).parent().removeClass("layui-input-active");
                }
            })
        })

	</script>
</body>
</html>